import {computed, reactive, toRefs} from "vue";
import {store} from '../store'

export default function () {
    const userDTO = store.state.users.userDTO
    //是否绑定
    const isBinding = computed(() => {
        return userDTO.customerUserDTO && userDTO.customerUserDTO.mobile
    })

    //显示的用户名
    const userName = computed(() => {
        return userDTO?.customerUserDTO?.nickName || userDTO?.wxMpUserDTO?.nickName
    })
    //手机号
    const phoneNumber = computed(() => {
        return userDTO?.customerUserDTO?.mobile || ''
    })
    //头像
    const headImgUrl = computed(() => {
        return store.state.users.userDTO.wxMpUserDTO?.headImgUrl
    })

    const getUserName = () => {
        return store.state.users.userDTO?.customerUserDTO?.nickName || store.state.users.userDTO?.wxMpUserDTO?.nickName
    }
    const getPhoneNumber = () => {
        return userDTO?.customerUserDTO?.mobile || ''
    }
    const getIdNumber = () => {
        return userDTO?.customerUserDTO?.idNumber || ''
    }
    const getBindName = () => {
        return userDTO?.customerUserDTO?.nickName || ''
    }
    const getSystemCode = () => {
        return userDTO?.customerUserDTO?.systemCode || ''
    }
    const getSystemName = () => {
        return userDTO?.customerUserDTO?.systemName || ''
    }
    const checkAllBindComplete = () => {
        return getBindName() && getIdNumber() && getPhoneNumber()
    }
    return {
        isBinding,
        userName,
        phoneNumber,
        headImgUrl,
        getUserName,
        getBindName,
        getIdNumber,
        getPhoneNumber,
        getSystemName,
        getSystemCode,
        checkAllBindComplete
    }
}
